import request from '@/config/axios'

export interface UserVO {
  id: number | string
  no: string | undefined
  avatar: string | undefined
  birthday: number | undefined
  createTime: number | undefined
  loginDate: number | undefined
  loginIp: string
  mark: string
  mobile: string
  name: string | undefined
  nickname: string | undefined
  registerIp: string
  sex: number
  status: number
  countyCode: number | string | undefined
  levelName: string | null
}

// 查询用户列表
export const getUserPage = async (params: any) => {
  return await request.get({ url: `/member/user/page`, params })
}

// 查询用户详情
export const getUser = async (id: number | string) => {
  return await request.get({ url: `/member/user/get?id=` + id })
}

// 查询用户数字资产
export const getDigitalAssets = async (userId: number | string) => {
  return await request.get({ url: `/member/digital-assets/get-by-user-id?userId=` + userId })
}

// 修改用户
export const updateUser = async (data: UserVO) => {
  return await request.put({ url: `/member/user/update`, data })
}

// 修改用户等级
export const updateUserLevel = async (data: any) => {
  return await request.put({ url: `/member/user/update-level`, data })
}

// 修改用户积分
export const updateUserPoint = async (data: any) => {
  return await request.put({ url: `/member/user/update-point`, data })
}

// 修改用户积分
export const updateUserCryptocurrency = async (data: any) => {
  return await request.put({ url: `/member/user/update-cryptocurrency`, data })
}

// 用户密码重置
export const resetUserPassword = (id: number | string, password: string) => {
  const data = {
    id,
    password
  }
  return request.put({ url: '/member/user/update-password', data: data })
}

// 查询用户列表（用于选择用户）
export const getUserListForPick = async (params: any) => {
  return await request.get({ url: `/member/user/pick`, params })
}
